import {View} from '@tarojs/components'
import {inject, observer} from 'mobx-react'

import './index.less'
import {observable} from "mobx";
import BaseComponent from "../BaseComponent";
import BluDeviceComService from "../../service/BluDeviceComService";
import LogService from "../../service/LogService";


@inject('store')
@observer
class Index extends BaseComponent {

  @observable statusBarHeight = 0;
  @observable imgIndex = 1;
  @observable title = "当前设备无法正常连接...";
  @observable deviceState = 0;  // 0 正在扫描  1 正在连接  2连接成功  3 连接失败
  @observable deviceId = undefined;

  @observable devices = [];
  taskNumb = undefined;
  scanTaskNumb = undefined;
  isScan = false;

  getTag() {
    return "device";
  }

  onLoad(option) {
    super.onLoad(option);

    if (!!option.deviceId){
      this.deviceId = option.deviceId;
      LogService.debug("deviceId", this.deviceId);
    }
  }


  disConnect = () => {
    BluDeviceComService.disconnetBlue(this.deviceId);
    super.redirectTo("../device/index");
  }

  render() {

    return (
      <View className='version'>
        <View className='device_name'>设备名称</View>
        <View className='device_info'
        >
          <View className='device_item_img'></View>
          <View className='device_info_name'>Tampo-y</View>
          <View className='device_item_right'>
            <View className='device_disconnect' onClick={this.disConnect}>退出连接</View>
          </View>
        </View>

        <View className='version_name'>版本号</View>
        <View className='device_info'>
          <View className='device_info_name'>0000000000</View>
        </View>
      </View>
    )
  }
}

export default Index
